/**
 * Offline Mode  离线模式
 * Reconnect to receive the missed messages
 * 重新连接接收离线时的消息
 */

var mqtt = require('mqtt');

var settings = {
  keepalive: 10,
  protocolId: 'MQIsdp',
  protocolVersion: 3,
  clientId: 'client-b',
  clean: false
}

client = mqtt.createClient(1883, 'localhost',settings);

client.on("message", function(topic, payload) {
  console.log('message: '+payload);
  console.log([topic,settings.clientId+'--->'+payload.toString()].join(": "));
  setTimeout(client.end(), 1000);
});
